<div class="dux-body">
    <div class="dux-box">
        <div class="box-side">
            <div class="am-panel am-panel-default dux-panel">
                <ul class="am-nav" data-dux="show-tab" data-active="am-active">
                    <li class="am-active"><a href="javascript:;" data-el="#tab1">基础信息</a></li>
                    <li><a href="javascript:;" data-el="#tab2">商品属性</a></li>
                    <li><a href="javascript:;" data-el="#tab3">商品介绍</a></li>
                    <!--loop{$hookHtml as $key => $vo}-->
                    <li><a href="javascript:;" data-el="#tab-{$key}">{$vo.name}</a></li>
                    <!--{/loop}-->
                </ul>
            </div>
        </div>
        <div class="box-body">

            <form class="am-form dux-form am-form-horizontal am-padding-top-0" data-dux="form-bind" method="post">

                <div class="dux-page-header am-padding-0 am-cf">
                    <div class="page-title">
                        <a class="am-btn am-btn-primary" href="{url('index', ['class_id' => $classId])}"> 商品列表</a>
                    </div>
                    <div class="page-action">
                        <a class="am-btn am-btn-danger" href="javascript:location.reload();"><i
                                class="am-icon-refresh"></i></a>
                    </div>
                </div>

                <div id="tab1">
                    <div class="am-panel am-panel-default dux-panel">

                        <div class="am-panel-hd">商品信息</div>
                        <div class="am-panel-bd">
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">商品分类</label>
                                <div class="am-u-md-10">
                                    <select data-dux="form-select" name="class_id" id="class_id" required>
                                        <!--loop{(array)$classList as $vo}-->
                                        <option <!--if{$vo.class_id == $classId}--> selected <!--{/if}-->
                                        value="{$vo.class_id}" data-spec="{$vo.spec_group_id}">{$vo.cname}</option>
                                        <!--{/loop}-->
                                    </select>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">商品标题</label>
                                <div class="am-u-md-10"><input type="text" name="title" value="{$info.title}" placeholder="请输入商品标题" required></div>
                            </div>


                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">副标题</label>
                                <div class="am-u-md-10">
                                    <input type="text" name="subtitle" value="{$info.subtitle}"
                                           placeholder="请输入副标题名称">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">商品品牌</label>
                                <div class="am-u-md-10">
                                    <select data-dux="form-select" data-placeholder="选择商品品牌"
                                            name="brand_id">
                                        <option></option>
                                        <!--loop{(array)$brandList as $vo}-->
                                        <option <!--if{$vo.brand_id == $info.brand_id}--> selected
                                        <!--{/if}-->
                                        value="{$vo.brand_id}">{$vo.name}</option>
                                        <!--{/loop}-->
                                    </select>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">推荐位</label>
                                <div class="am-u-md-10">
                                    <?php $posIds = explode(',', $info['pos_id']); ?>
                                    <select name="pos_id[]" multiple
                                            data-am-selected="{btnWidth: '100%'}">
                                        <!--loop{$posList as $vo}-->
                                        <option value="{$vo.pos_id}"
                                        <!--if{in_array($vo.pos_id, $posIds)}-->
                                        selected
                                        <!--{/if}-->>{$vo.name}</option>
                                        <!--{/loop}-->
                                    </select>
                                </div>
                            </div>

                            <div class="filter-body">
                                {$filterHtml}
                            </div>


                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">商品图片</label>
                                <div class="am-u-md-10">
                                    <button class="am-btn am-btn-success" type="button" data-dux="form-images"
                                            data-img-list='{json_encode(unserialize($info.images))}'
                                            data-img-name="images"
                                            data-img-warp="#dux-images-images"
                                            data-type="jpg,png,bmp"
                                            data-resize="{width : 500, height: 500, crop: true}">
                                        上传组图
                                    </button>
                                    <ul class="dux-images am-cf" id="dux-images-images"></ul>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">规格属性</label>
                                <div class="am-u-md-10">
                                    <table class="am-table dux-table-dialog" style="border: 1px solid #ddd">
                                        <thead>
                                        <tr>
                                            <th width="130">规格
                                                <a href="javascript:;" id="add-spec-group">
                                                    <i class="am-icon-plus"></i>
                                                </a>
                                            </th>
                                            <th>规格值</th>
                                        </tr>
                                        </thead>
                                        <tbody class="dux-spec-group">
                                        </tbody>
                                    </table>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">商品规格</label>
                                <div class="am-u-md-10">
                                    <div class="js-data-list"></div>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">商品单位</label>
                                <div class="am-u-md-10">
                                    <input type="text" name="unit" value="{$info.unit ? $info.unit : '个'}" placeholder="商品单位" required>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">商品状态</label>
                                <div class="am-u-md-10">
                                    <?php $info['status'] = isset($info['status']) ? $info['status'] : 1;  ?>
                                    <label class="am-radio-inline">
                                        <!--if{$info['status']}-->
                                        <input name="status" value="1" checked="checked" type="radio">
                                        <!--{else}-->
                                        <input name="status" value="1" type="radio">
                                        <!--{/if}-->
                                        正常
                                    </label>
                                    <label class="am-radio-inline">
                                        <!--if{!$info['status']}-->
                                        <input name="status" checked="checked" value="0" type="radio">
                                        <!--{else}-->
                                        <input name="status" value="0" type="radio">
                                        <!--{/if}-->
                                        隐藏
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div id="tab2">
                    <div class="am-panel am-panel-default dux-panel">
                        <div class="am-panel-hd">
                            高级属性
                        </div>
                        <div class="am-panel-bd">

                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">赠送积分</label>
                                <div class="am-u-md-10">
                                    <label class="am-radio-inline">
                                        <?php $info['point_status'] = isset($info['point_status']) ? $info['point_status'] : 1;  ?>
                                        <!--if{$info['point_status']}-->
                                        <input name="point_status" value="1" checked="checked" type="radio">
                                        <!--{else}-->
                                        <input name="point_status" value="1" type="radio">
                                        <!--{/if}-->
                                        支持
                                    </label>
                                    <label class="am-radio-inline">
                                        <!--if{!$info['point_status']}-->
                                        <input name="point_status" checked="checked" value="0" type="radio">
                                        <!--{else}-->
                                        <input name="point_status" value="0" type="radio">
                                        <!--{/if}-->
                                        不支持
                                    </label>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">发布时间</label>
                                <div class="am-u-md-10">
                                    <input type="text" data-dux="form-date" data-format="yyyy-mm-dd hh:ii"
                                           name="create_time"
                                           value="{$info.create_time ? date('Y-m-d H:i', $info.create_time) : date('Y-m-d H:i')}"
                                           placeholder="商品发布时间" readonly>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">上架时间</label>
                                <div class="am-u-md-10">
                                    <input type="text" data-dux="form-date" data-format="yyyy-mm-dd hh:ii" name="up_time" value="{$info.up_time ? date('Y-m-d H:i', $info.up_time) : ''}" placeholder="商品上架时间" readonly>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">下架时间</label>
                                <div class="am-u-md-10">
                                    <input type="text" data-dux="form-date" data-format="yyyy-mm-dd hh:ii" name="down_time" value="{$info.down_time ? date('Y-m-d H:i', $info.down_time) : ''}" placeholder="商品下架时间" readonly>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">浏览量</label>
                                <div class="am-u-md-10">
                                    <input type="number" name="view" value="{$info.view}" placeholder="商品浏览次数">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">商品顺序</label>
                                <div class="am-u-md-10">
                                    <input type="text" name="sort" value="{$info.sort ? $info.sort : 0}" placeholder="商品排序,按照从大->小排序列表">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">外部链接</label>
                                <div class="am-u-md-10">
                                    <input type="text" name="url" value="{$info.url}" placeholder="请输入链接地址">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">模板名称</label>
                                <div class="am-u-md-10">
                                    <select data-dux="form-select" name="tpl" style="width: 100%" data-placeholder="可选专属模板">
                                        <option value="">==默认==</option>
                                        <!--loop{$tplList as $vo}-->
                                        <option value="{$vo.value}" <!--if{$info.tpl == $vo.value}-->  selected
                                        <!--{/if}-->
                                        >{$vo.name}</option>
                                        <!--{/loop}-->
                                    </select>

                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="am-panel am-panel-default dux-panel">
                        <div class="am-panel-hd">
                            配送设置
                        </div>
                        <div class="am-panel-bd">
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">退换货</label>
                                <div class="am-u-md-10">
                                    <label class="am-radio-inline">
                                        <!--if{$info['service_status']}-->
                                        <input name="service_status" value="1" checked="checked" type="radio">
                                        <!--{else}-->
                                        <input name="service_status" value="1" type="radio">
                                        <!--{/if}-->
                                        支持
                                    </label>
                                    <label class="am-radio-inline">
                                        <!--if{!$info['service_status']}-->
                                        <input name="service_status" checked="checked" value="0" type="radio">
                                        <!--{else}-->
                                        <input name="service_status" value="0" type="radio">
                                        <!--{/if}-->
                                        不支持
                                    </label>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">货到付款</label>
                                <div class="am-u-md-10">
                                    <label class="am-radio-inline">
                                        <!--if{$info['cod_status']}-->
                                        <input name="cod_status" value="1" checked="checked" type="radio">
                                        <!--{else}-->
                                        <input name="cod_status" value="1" type="radio">
                                        <!--{/if}-->
                                        支持
                                    </label>
                                    <label class="am-radio-inline">
                                        <!--if{!$info['cod_status']}-->
                                        <input name="cod_status" checked="checked" value="0" type="radio">
                                        <!--{else}-->
                                        <input name="cod_status" value="0" type="radio">
                                        <!--{/if}-->
                                        不支持
                                    </label>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">运费类型</label>
                                <div class="am-u-md-10">
                                    <label class="am-radio-inline">
                                        <!--if{$info['freight_type']}-->
                                        <input name="freight_type" value="1" checked="checked" type="radio">
                                        <!--{else}-->
                                        <input name="freight_type" value="1" type="radio">
                                        <!--{/if}-->
                                        模板运费
                                    </label>
                                    <label class="am-radio-inline">
                                        <!--if{!$info['freight_type']}-->
                                        <input name="freight_type" checked="checked" value="0" type="radio">
                                        <!--{else}-->
                                        <input name="freight_type" value="0" type="radio">
                                        <!--{/if}-->
                                        固定运费
                                    </label>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">运费模板</label>
                                <div class="am-u-md-10">
                                    <select name="freight_tpl" class="select-filter" data-dux="form-select" style="width: 100%" data-placeholder="请选择运费模板" tabindex="-1">
                                        <!--loop{(array)$deliveryList as $key => $vo}-->
                                        <option value="{$vo.delivery_id}" {$vo.delivery_id == $info.freight_tpl ? 'selected' : ''} >{$vo.name}</option>
                                        <!--{/loop}-->
                                    </select>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">固定运费</label>
                                <div class="am-u-md-10">
                                    <input type="text" name="freight_price" value="{$info.freight_price}" placeholder="固定运费，0为包邮">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div id="tab3">

                    <div class="am-panel am-panel-default dux-panel">
                        <div class="am-panel-hd">商品详情</div>
                        <div class="am-panel-bd">
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">详情内容</label>
                                <div class="am-u-sm-10">
                                    <textarea data-dux="form-editor" name="content" id="content" style="height: 500px">{$info.content}</textarea>
                                </div>
                            </div>

                            {$modelHtml}

                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">关键词</label>
                                <div class="am-u-sm-10">
                                    <input type="text" name="keyword" value="{$info.keyword}" data-dux="form-tags" placeholder="可选,商品关键词">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-md-2 am-form-label">商品描述</label>
                                <div class="am-u-sm-10">
                                    <textarea name="description" placeholder="可选,商品描述">{$info.description}</textarea>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

                <!--loop{$hookHtml as $key => $vo}-->
                <div id="tab-{$key}">
                    {$vo.html}
                </div>
                <!--{/loop}-->

                <div class="am-panel am-panel-default dux-panel">
                    <div class="am-panel-bd">
                        <div class="am-form-group am-margin-bottom-0">
                            <div class="am-u-sm-10 am-u-sm-offset-2">
                                <input type="hidden" name="content_id" value="{$info.content_id}">
                                <input type="hidden" name="mall_id" value="{$info.mall_id}">
                                <input type="hidden" name="app" value="mall">
                                <button class="am-btn am-btn-primary" type="submit" disabled>保存</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script id="tpl-spec" type="text/html">
    {{# var specList = d.data.spec_list; }}
    {{# var specCount = specList.length; }}
    <div class="am-scrollable-horizontal">
        <table class="am-table dux-table-dialog  am-text-nowrap" style="border: 1px solid #ddd">
            <thead>
            <tr>
                {{# var head = d.head; }}
                {{# for(var i in head){ }}
                <th>{{ head[i].name }}</th>
                {{# } }}
                <th>商品货号</th>
                <th width="80">销售价 <a href="javascript:;" class="am-icon-edit spec-value-set"></a></th>
                <th width="80">市场价 <a href="javascript:;" class="am-icon-edit spec-value-set"></a></th>
                <th width="80">成本价 <a href="javascript:;" class="am-icon-edit spec-value-set"></a></th>
                <th width="80">库存 <a href="javascript:;" class="am-icon-edit spec-value-set"></a></th>
                <th width="80">重量(克) <a href="javascript:;" class="am-icon-edit spec-value-set"></a></th>
                {{# if(specCount > 1){ }}
                <th class="uk-text-center" width="60">操作</th>
                {{# } }}
            </tr>
            </thead>
            <tbody>
            {{# for(var i in specList){ }}
            <tr>
                <input type="hidden" name="data[id][{{ i }}]" {{# if(!$.isEmptyObject(d.data.id[i])){ }}
                       value="{{ d.data.id[i] }}" {{# } }}/>
                {{# for(var item in specList[i]){ }}
                <input type="hidden" name="data[spec][{{ i }}][]" value='{{ JSON.stringify(specList[i][item]) }}'>
                <td>{{ specList[i][item].value }}</td>
                {{# } }}
                <td><input class="goods_no" type="text" name="data[goods_no][{{ i }}]" {{#
                           if(!$.isEmptyObject(d.data.goods_no[i])){ }} value="{{ d.data.goods_no[i] }}" {{# }else{
                           }}
                           value="{{ defaultProductNo+'_'+i }}" {{# } }}></td>
                <td><input class="sell_price" type="text" name="data[sell_price][{{ i }}]" {{#
                           if(!$.isEmptyObject(d.data.sell_price[i])){ }} value="{{ d.data.sell_price[i] }}" {{# }
                           }}>
                </td>
                <td><input class="market_price" type="text" name="data[market_price][{{ i }}]" {{#
                           if(!$.isEmptyObject(d.data.market_price[i])){ }} value="{{ d.data.market_price[i] }}" {{#
                           }
                           }}>
                </td>
                <td><input class="cost_price" type="text" name="data[cost_price][{{ i }}]" {{#
                           if(!$.isEmptyObject(d.data.cost_price[i])){ }} value="{{ d.data.cost_price[i] }}" {{# }
                           }}>
                </td>
                <td><input class="store" type="text" name="data[store][{{ i }}]" {{#
                           if(!$.isEmptyObject(d.data.store[i])){ }} value="{{ d.data.store[i] }}" {{# } }}></td>
                <td><input class="weight" type="text" name="data[weight][{{ i }}]" {{#
                           if(!$.isEmptyObject(d.data.weight[i])){ }} value="{{ d.data.weight[i] }}" {{# } }}></td>
                {{# if(specCount > 1){ }}
                <td class="am-text-center">
                    <a href="javascript:;" class="am-btn am-btn-danger am-btn-sm js-del am-icon-remove"></a>
                </td>
                {{# } }}
            </tr>
            {{# } }}
            </tbody>
        </table>
    </div>
</script>
<script id="tpl-spec-default" type="text/html">
    <div class="am-scrollable-horizontal">
        <table class="am-table dux-table-dialog am-text-nowrap" style="border: 1px solid #ddd">
            <thead>
            <tr>
                <th>商品货号</th>
                <th width="80">销售价</th>
                <th width="80">市场价</th>
                <th width="80">成本价</th>
                <th width="80">库存</th>
                <th width="80">重量(克)</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td><input class="goods_no" type="text" name="data[goods_no][0]" value="{{ d.no }}"></td>
                <td><input class="sell_price" type="text" name="data[sell_price][0]" value=""></td>
                <td><input class="market_price" type="text" name="data[market_price][0]" value=""></td>
                <td><input class="cost_price" type="text" name="data[cost_price][0]" value=""></td>
                <td><input class="store" type="text" name="data[store][0]" value=""></td>
                <td><input class="weight" type="text" name="data[weight][0]" value=""></td>
            </tr>
            </tbody>
        </table>
    </div>
</script>
<!--include{app/shop/static/tpl/content_edit}-->